import React from 'react';
import { Switch, HashRouter, Route, Redirect } from 'react-router-dom';

// import Common, { CommonContext } from 'components/Common';

import Main from 'container/main';
import ConditionSearchPage from 'container/conditionSearchPage';
import FED4 from 'container/FED4';
import Proxy from 'container/Proxy';
// import Login from 'container/login';
// import Register from 'container/register';
// import Home from 'container/home';
// import Account from 'container/account';
// import AccountsTheme from 'container/accountsTheme';
// import BatchAdd from 'container/batchAdd';

export const Routes = [
    { path: 'main', name: '首页', component: Main, exact: true },
    { path: 'conditionSearch', name: '多条件筛选', component: ConditionSearchPage, exact: true },
    { path: 'FED4', name: 'FED4 根据包名，在指定空间中创建对象', component: FED4 },
    { path: 'proxy', name: 'Proxy学习,实现一个数据响应式', component: Proxy },
    // { path: 'login', name: '登陆', component: Login, exact: true },
    // { path: 'register', name: '注册', component: Register, exact: true },
    // { path: 'home', name: '用户首页', component: Home, exact: true },
    // { path: 'accounts', name: '账户管理页', component: Account, exact: true },
    // { path: 'accountsTheme', name: '账户管理页', component: AccountsTheme, exact: true },
    // { path: 'batchAdd', name: '账户管理页', component: BatchAdd, exact: true },
];


export default function () {
    return (
        // <CommonContext.Provider value={Common()}>
        <HashRouter>
            <Switch>
                {
                    Routes.map(o =>
                        <Route
                            key={o.path}
                            exact={o.exact}
                            path={`/${o.path}`}
                            render={
                                (prop) => {
                                    return <o.component {...prop} Routes={o.children || o.sibling || []} />
                                }
                            }
                        />
                    )
                }
                <Redirect from={'/'} to={'main'} />
            </Switch>
        </HashRouter>
        // </CommonContext.Provider>
    );
}